<template>
	<view class="container">
		<view class="top-c global-shadow">
			<text class="new-iconfont icon-express"></text>
			<view class="right">
				<view class="name">{{deliverRecord.express_name}}</view>
				<view class="number">单号: {{deliverRecord.express_number}}</view>
			</view>
		</view>
		<view class="body list">
			<TimelineItem class="item" middleText="收" :height="138" v-if="address">
				<View clsas="middle" slot="middle">收</View>
				<view class="right" slot="right">
					<view class="address-title">收货地址</view>
					<view class="text">{{address.province}}{{address.city}}{{address.district}}{{address.address}}</view>
					<!-- <text class="title">{{item.title}}</text>
					<text class="day" v-if="item.day">{{item.day}}个工作日</text> -->
				</view>
			</TimelineItem>
			<TimelineItem class="item" :height="item.context.length * 2" :pending="item.pending" :isLast="index === (list.length - 1)" v-for="(item, index) in list" :key="index">
				<view class="left" :class="{pending: item.pending}" slot="left">
					<text class="day">{{item.day_at}}</text>
					<text class="time">{{item.time_at}}</text>
				</view>
				<view class="right" :class="{pending: item.pending}" slot="right">
					<text class="text">{{item.context}}</text>
					<!-- <text class="title">{{item.title}}</text>
					<text class="day" v-if="item.day">{{item.day}}个工作日</text> -->
				</view>
			</TimelineItem>
		</view>
	</view>
</template>

<script>
	import TimelineItem from "./components/TimelineItem.vue"
	export default {
		components: {
			TimelineItem
		},
		data() {
			return {
				uuid: '',
				deliverRecord: {},
				list: [],
				address: null
			}
		},
		computed: {
		},
		onLoad(e) {
			this.uuid = e.uuid
			this.initData()
		},
		watch: {
		},
		methods: {
			initData () {
				// this.$loading.show()
				uni.showLoading({
					title: '查询中~'
				})
				this.$http(`/orders/${this.uuid}/express/info`).then(res => {
					uni.hideLoading()
					
					this.list = res.data.list.map((item, index) => {
						let time = item.time
						item.day_at = time.substr(5, 6)
						item.time_at = time.substr(11, 5)
						item.pending = index !== 0
						return item
					})
					
					if (this.list.length === 0) {
						this.list.push({
							day_at: '',
							time_at: '',
							context: '暂无物流信息'
						})
					}
					
					this.deliverRecord = res.data.deliver_record 
					this.address = res.data.address
				})
				
				// this.$api.emit('core.deliverRecord.show', this.uuid).then(res => {
				// 	this.deliverRecord = res.data.info
				// 	this.address = res.data.address
				// })
			}
		},
		onShow () {
			// this.initData()
		}
	}
</script>

<style lang="scss">
	page {
		background: #FAFAFA;
	}
</style>

<style lang="scss" scoped>
	.container {
		padding-top: 150rpx;
		padding-bottom: 100rpx;
		.top-c {
			// position: fixed;
			padding: 30rpx 60rpx;
			background: white;
			display: flex;
			align-items: center;
			position: fixed;
			top: 0rpx;
			width: 100%;
			background: white;
			z-index: 10;
			
			.icon-express {
				font-size: 100rpx;
				margin-right: 50rpx;
			}
			
			.right {
				.name {
					font-size: 36rpx;
					font-weight: bold;
					color: #585858;
				}
				.number {
					font-weight: 500;
					margin-top: 10rpx;
					color: #585858;
				}
			}
		}
		
		.list {
			margin-top: 60rpx;
			padding-left: 30rpx;
			padding-right: 40rpx;
			.item {
				.left {
					text-align: right;
					.day {
						display: block;
						color: #585858;
						font-size: 24rpx;
						font-weight: bold;
					}
					.time {
						color: #8C8C8C;
						font-size: 20rpx;
					}
					&.pending {
						.day {
							font-size: 20rpx;
							color: #8C8C8C;
						}
					}
				}
				.right {
					.text {
						font-size: 24rpx;
						color: #585858;
						text-align: justify;
					}
					.address-title {
						font-weight: bold;
						font-size: 24rpx;
					}
					&.pending {
						.text {
							color: #8C8C8C;
						}
					}
				}
			}
		}
		
	}
</style>
